package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WGoodsTheoryWeight;
import com.ruoyi.system.service.IWGoodsTheoryWeightService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 货物理重Controller
 * 
 * @author wzy
 * @date 2024-08-30 15:52:52
 */
@RestController
@RequestMapping("/system/theoryweight")
public class WGoodsTheoryWeightController extends BaseController
{
    @Autowired
    private IWGoodsTheoryWeightService wGoodsTheoryWeightService;

    /**
     * 查询货物理重列表
     */
    @PreAuthorize("@ss.hasPermi('system:theoryweight:list')")
    @GetMapping("/list")
    public TableDataInfo list(WGoodsTheoryWeight wGoodsTheoryWeight)
    {
        startPage();
        List<WGoodsTheoryWeight> list = wGoodsTheoryWeightService.selectWGoodsTheoryWeightList(wGoodsTheoryWeight);
        return getDataTable(list);
    }

    /**
     * 导出货物理重列表
     */
    @PreAuthorize("@ss.hasPermi('system:theoryweight:export')")
    @Log(title = "货物理重", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WGoodsTheoryWeight wGoodsTheoryWeight)
    {
        List<WGoodsTheoryWeight> list = wGoodsTheoryWeightService.selectWGoodsTheoryWeightList(wGoodsTheoryWeight);
        ExcelUtil<WGoodsTheoryWeight> util = new ExcelUtil<WGoodsTheoryWeight>(WGoodsTheoryWeight.class);
        util.exportExcel(response, list, "货物理重数据");
    }

    /**
     * 获取货物理重详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:theoryweight:query')")
    @GetMapping(value = "/{goodsTheoryWeightId}")
    public AjaxResult getInfo(@PathVariable("goodsTheoryWeightId") Long goodsTheoryWeightId)
    {
        return success(wGoodsTheoryWeightService.selectWGoodsTheoryWeightByGoodsTheoryWeightId(goodsTheoryWeightId));
    }

    /**
     * 新增货物理重
     */
    @PreAuthorize("@ss.hasPermi('system:theoryweight:add')")
    @Log(title = "货物理重", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WGoodsTheoryWeight wGoodsTheoryWeight)
    {
        wGoodsTheoryWeight.setCreateBy(getNickName());
        return toAjax(wGoodsTheoryWeightService.insertWGoodsTheoryWeight(wGoodsTheoryWeight));
    }

    /**
     * 修改货物理重
     */
    @PreAuthorize("@ss.hasPermi('system:theoryweight:edit')")
    @Log(title = "货物理重", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WGoodsTheoryWeight wGoodsTheoryWeight)
    {
        wGoodsTheoryWeight.setUpdateBy(getNickName());
        return toAjax(wGoodsTheoryWeightService.updateWGoodsTheoryWeight(wGoodsTheoryWeight));
    }

    /**
     * 删除货物理重
     */
    @PreAuthorize("@ss.hasPermi('system:theoryweight:remove')")
    @Log(title = "货物理重", businessType = BusinessType.DELETE)
	@DeleteMapping("/{goodsTheoryWeightIds}")
    public AjaxResult remove(@PathVariable Long[] goodsTheoryWeightIds)
    {
        return toAjax(wGoodsTheoryWeightService.deleteWGoodsTheoryWeightByGoodsTheoryWeightIds(goodsTheoryWeightIds));
    }

    /**
     * 字典项产地
     */
//    @PreAuthorize("@ss.hasPermi('system:theoryweight:list')")
    @GetMapping("/listproductoption")
    public AjaxResult listProductOption(WGoodsTheoryWeight wGoodsTheoryWeight)
    {
        return success(wGoodsTheoryWeightService.selectProductOptionByWGoodsTheoryWeight(wGoodsTheoryWeight));
    }

    /**
     * 字典项规格
     */
//    @PreAuthorize("@ss.hasPermi('system:theoryweight:list')")
    @GetMapping("/listspecificationoption")
    public AjaxResult listSpecificationOption(WGoodsTheoryWeight wGoodsTheoryWeight)
    {
        return success(wGoodsTheoryWeightService.selectSpecificationOptionByWGoodsTheoryWeight(wGoodsTheoryWeight));
    }

    /**
     * 字典项材质
     */
//    @PreAuthorize("@ss.hasPermi('system:theoryweight:list')")
    @GetMapping("/liststeelgradeoption")
    public AjaxResult listSteelGradeOption(WGoodsTheoryWeight wGoodsTheoryWeight)
    {
        return success(wGoodsTheoryWeightService.selectSteelGradeOptionByWGoodsTheoryWeight(wGoodsTheoryWeight));
    }

}
